package D1;

import java.awt.Color;
import javax.swing.JPanel;


public class AlloneJPanel extends JPanel implements Runnable{

	int x=500,y=600;

	Thread t;  
	
	public AlloneJPanel() {  
		setBackground(Color.BLACK);

		t=new Thread(this);

		t.start();
	}
	

	public void paint(java.awt.Graphics g) {
		super.paint(g); 
		g.setColor(Color.white);

		for(int i=0;i<300;i++){
		g.drawString("*", (int)(Math.random()*x), (int)(Math.random()*y)); 

		}
	}

	public void run() {  
		while(true){
			y++;  
			if(y==600){
				y=0;
			}
		
			repaint();

			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		
	}
}
